/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package eu.fsiebert.polytech.db.mediatheque.session;

import eu.fsiebert.polytech.db.mediatheque.entity.Adherent;
import eu.fsiebert.polytech.db.mediatheque.entity.CommandeDuJour;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author Florent
 */
@Stateless
public class CommandeDuJourFacade extends AbstractFacade<CommandeDuJour> {
    @PersistenceContext(unitName = "mediatheque")
    private EntityManager em;
    
    
    protected EntityManager getEntityManager() {
        return em;
    }

    public CommandeDuJourFacade() {
        super(CommandeDuJour.class);
    }

    public CommandeDuJour findByUser(Adherent adherent) {
        Query query = em.createNamedQuery("CommandeDuJour.findByAdherent");
        query.setParameter("adherent", adherent);
        return (CommandeDuJour) query.getSingleResult();
    }
    
}
